package com.inventive.system.monitoring.server.service.publisher.sample;

import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Service;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * User: Grant Little <grant.little@inventivesoftware.com.au>
 */
@Service
@ManagedResource(objectName = "Sample:bean=SampleJMXBean1")
public class SampleJMXBean1 {

    private String status = "RUNNING";

    private AtomicInteger counter;

    public SampleJMXBean1() {
        counter = new AtomicInteger(0);
    }

    @ManagedAttribute(description = "The current status of the bean")
    public String getStatus() {
        return status;
    }

    @ManagedAttribute(description = "The current status of the bean")
    public void setStatus(String status) {
        this.status = status;
    }

    @ManagedAttribute(description = "The current value of the counter")
    public int getCounter() {
        return counter.getAndIncrement();
    }
}
